<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%--常量--%>
    <%@ include file="/common/constHead.jsp"%>
    <%--jQuery--%>
    <%@ include file="/common/jqueryHead.jsp"%>
    <%--jo--%>
    <%@ include file="/common/joHead.jsp"%>
    <%--bootstrap和字体--%>
    <%@ include file="/common/bootstrapHead.jsp"%>
    <%--layer--%>
    <%@ include file="/common/layerHead.jsp"%>
    <%--zTree树--%>
    <%@ include file="/common/zTreeHead.jsp"%>
    <%--公共--%>
    <%@ include file="/common/commonHead.jsp"%>
    <title>旅游资源单体调查</title>
    <script type="text/javascript">
        $(function(){
            createTree("stTree",function(event,treeId,treeNode){
                if(treeNode.stype == "1"){//主类
                    joView.params.condition = "typeOne=" + treeNode.id;
                }else if(treeNode.stype == "2"){//父类
                    joView.params.condition = "typeTwo=" + treeNode.id;
                }else if(treeNode.stype == "3"){//基本类型
                    joView.params.condition = "typeThree=" + treeNode.id;
                }
                joView.select();
            });
            joView.init({grid:$("#mainList"),PKName:"id",formWidth:"1000px",winTitleOfAdd:"新建旅游资源单体信息",winTitleOfUpdate:"旅游资源单体信息"});//初始化页面
        });
        //行处理
        joView.handleItem = function(oItem,iIndex){

        };
        function createTree(eleId,clickFunc){
            eleId = jo.getDefVal(eleId, "stTree");
            jo.postAjax("travel/sourceType/getSourceTypeList.action", {}, function(json){
                if(json && json.code == 0){
                    /*if(json && json.data && json.data[0] && json.data[0].ID == "ROOT"){
                        json.data[0].open = true;
                    }*/
                    var param = {
                        treeId : eleId
                        ,zNodes : json.data
                        ,item_id : "id"
                        ,item_pid : "parentId"
                        ,item_show : "name"
                    };
                    if(typeof (clickFunc) == "function"){
                        param.onClickFunc = clickFunc;//树节点点击回调
                    }
                    jo.drawZTree(param);
                }else{
                    jo.showMsg("创建树失败!");
                }
            });
        }
        joView.add = function(sUrl,sWidth,sHeight,sTitle){
            var sUrl = jo.getDefVal(sUrl,joView.params["formUrl"]);
            if(jo.isValid(sUrl)){
                sUrl = sUrl + jo.getLinkSign(sUrl) + joView.params["transferParam"];
                //getPopWin(sUrl,jo.getDefVal(sWidth,'780px'),jo.getDefVal(sHeight,'80%'),jo.getDefVal(sTitle,'新增'));
                top.jo.showWin(sUrl,jo.getDefVal(sWidth, joView.params["formWidth"]),jo.getDefVal(sHeight, joView.params["formHeight"]),jo.getDefVal(sTitle, joView.params["winTitleOfAdd"]), joView.params["winNameOfAdd"]);
            }
        };
        joView.edit = function(id,sWidth,sHeight,sTitle){
            if(typeof(joView.clickItem) == "function"){
                joView.clickItem(id,sWidth,sHeight,sTitle);
            }else{
                if(jo.isValid(joView.params["formUrl"])){//有效的表单地址
                    if(typeof(sWidth) == "object"){
                        sWidth = '';
                    }
                    //getPopWin(joView.params["formUrl"]+jo.getLinkSign(joView.params["formUrl"])+joView.params["PKName"]+'='+id +"&"+ joView.params["transferParam"],jo.getDefVal(sWidth,'780px'),jo.getDefVal(sHeight,'80%'),jo.getDefVal(sTitle,'编辑'));
                    top.jo.showWin(joView.params["formUrl"]+jo.getLinkSign(joView.params["formUrl"])+joView.params["PKName"]+'='+id +"&"+ joView.params["transferParam"],jo.getDefVal(sWidth, joView.params["formWidth"]),jo.getDefVal(sHeight, joView.params["formHeight"]),jo.getDefVal(sTitle, joView.params["winTitleOfUpdate"]), joView.params["winNameOfUpdate"]);
                }
            }
        };
    </script>
</head>
<body>

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
            <%--检索栏--%>
            <form class="form-inline search-bar" id="pageForm">
                <div class="form-group">
                    <label class="control-label">编号：&nbsp;</label>
                    <input type="text" name="id" class="form-control input-sm" value="">
                </div>
                <div class="form-group">
                    <label class="control-label">名称：&nbsp;</label>
                    <input type="text" name="name" class="form-control input-sm" value="">
                </div>
                <button type="button" class="btn btn-primary btn-sm" onclick="joView.select()"> <i class="fa fa-search" aria-hidden="true"></i>&nbsp;查询</button>
            </form>
            <%--/检索栏--%>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
            <%--按钮栏--%>
            <div class="form-group button-bar" style="padding-top: 0px;">
                <button isShow="" type="button" class="btn btn-sm btn-outline btn-primary" onclick="joView.add()">
                    <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;新增
                </button>
                <button type="button" class="btn btn-sm btn-outline btn-danger" onclick="joView.del()">
                    <i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;删除
                </button>
                <button type="button" class="btn btn-sm btn-outline btn-warning" onclick="window.location.reload()">
                    <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                </button>
            </div>
            <%--/按钮栏--%>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-3 col-lg-2">
            <div style="font-size: 14px;">&nbsp;&nbsp;<b>旅游资源类型</b></div>
            <div id="stTree" class="ztree">

            </div>
        </div>
        <div class="col-xs-9 col-lg-10">
            <%--grid--%>
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-striped table-condensed" id="mainList" dataUrl="travel/source/getSourcePage.action" deleteUrl="travel/source/delete.action" formUrl="page/travel/surveyForm.jsp">
                    <col field="name" title="名称" width="25%" align="left" event="click"/>
                    <col field="{typeThree}-{typeThreeName}" title="基本类型" width="15%" align=""/>
                    <col field="addr" title="行政地址" width="20%" align=""/>
                    <col field="latitude" title="东经" width="10%" align=""/>
                    <col field="longitude" title="北纬" width="10%" align=""/>
                </table>
            </div>
            <%--/grid--%>

            <%--分页条--%>
            <div class="page-bar" gridId="mainList">

            </div>
            <%--/分页条--%>
        </div>
    </div>
</div>

<script src="<%=URL_STATIC%>static/plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    jo.formatUI();//格式化jo组件
</script>
</body>
</html>
